package com.demo;

/*
Future获取线程任务执行结果
 */

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.*;

class Demo11Thread implements Callable<List> {
    @Override
    public List call() throws Exception {
        Thread.sleep(2000);
        List list = new ArrayList();
        list.add(1);
        list.add(2);
        list.add(3);
        return list;
    }
}
public class Demo11 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newCachedThreadPool();
        Future<List> future = executorService.submit(new Demo11Thread());
        List list = future.get();
        System.out.println("list = " + list.size());
    }
}
